package net.qhzw.admin.controller;

import net.qhzw.admin.entity.SysRole;
import net.qhzw.admin.mapper.SysRoleMapper;
import net.qhzw.admin.param.RoleParam;
import net.qhzw.admin.query.RoleQuery;
import net.qhzw.admin.service.SysRoleService;
import net.qhzw.common.model.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("sys/role")
public class SysRoleController {

    @Autowired
    private SysRoleService roleService;

    @GetMapping("/{id}")
    public JsonResult getRole(@PathVariable(value = "id") String id){
        return roleService.getRole(id);
    }

    @GetMapping
    public JsonResult getRoleAll(RoleQuery query){
        return roleService.getRoleAll(query);
    }

    @PostMapping
    public JsonResult addRole(@RequestBody RoleParam role){
        return roleService.edit(role);
    }


    @PutMapping
    public JsonResult updateRole(@RequestBody RoleParam role){
        return roleService.edit(role);
    }


    @DeleteMapping("/{id}")
    public JsonResult deleteRole(@PathVariable(value = "id") String id){
        return roleService.deleteRole(id);
    }


}
